interface IfileReadScope extends ng.IScope {
    uploader:any;

}
function fileRead($window:ng.IWindowService){
    
    return {
        scope: {
            uploader: "="
        },
        restrict:'A',
        link:(scope : IfileReadScope, element : ng.IAugmentedJQuery, attributes : ng.IAttributes)=>{
            // console.log('fileread')
            // console.log(element)
         
            element.bind('change',(e)=>{
              
                scope.uploader.addByFile(e.target['files'][0])
                
                scope.$apply(()=>{scope.uploader});
                e.target['value']='';
            })
        }
    }
}
fileRead['$inject'] = ["$window"];
angular.module('tms').directive('fileRead', fileRead);